﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctrl="clr-namespace:CBR.Components.Controls" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d">

    <!-- Style for the Clear Button -->
    <Style x:Key="ClearButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
					
                        <Grid Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center">
							<Path x:Name="path1" Stretch="Fill" Stroke="{DynamicResource CbrBackgroundSelected}" Data="M0,0 L8,8" StrokeThickness="4" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
							<Path x:Name="path2" Stretch="Fill" Stroke="{DynamicResource CbrBackgroundSelected}" Data="M8,0 L0,8" StrokeThickness="4" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
                        </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Stroke" TargetName="path1" Value="{DynamicResource CbrBorderBrushSelected}"/>
							<Setter Property="Stroke" TargetName="path2" Value="{DynamicResource CbrBorderBrushSelected}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FilterTextBoxStyle" TargetType="{x:Type TextBox}">
		<Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0"/>
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="Foreground" Value="{DynamicResource CbrForegroundBrush}"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource CbrForegroundDisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ctrl:FilterControl}">
    	<Setter Property="MinHeight" Value="29"/>
		<Setter Property="Foreground" Value="{DynamicResource CbrForegroundBrush}"/>
		<Setter Property="Background" Value="{DynamicResource CbrTextBoxBackground}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:FilterControl}">
                    <Border x:Name="border" BorderThickness="0" IsEnabled="{TemplateBinding IsEnabled}"
							Background="{TemplateBinding Background}" >					
                		<Grid Margin="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>                			
							<Image Margin="1,0,1,0" Height="18" Source="/CBR;Component/Resources/Images/32x32/action/search.png"/>
                			<TextBox Style="{StaticResource FilterTextBoxStyle}"
                                     x:Name="PART_FilterBox"  AutoWordSelection="True"
                                     Grid.Column="1"
                                     Margin="0" VerticalAlignment="Center"/>
                            <TextBlock x:Name="PART_Header" Text="{TemplateBinding Header}"  VerticalAlignment="Center" HorizontalAlignment="Left"
								Margin="0" Grid.Column="1" IsHitTestVisible="False" Foreground="{TemplateBinding Foreground}"/>
                			<Button x:Name="PART_ClearButton" Grid.Column="2" Margin="0,0,4,0" Style="{StaticResource ClearButtonStyle}" 
                                   Visibility="Hidden" />
                		</Grid>
                	</Border>
                    <ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True" >
							<Setter Property="Background" Value="{DynamicResource CbrTextBoxBackgroundSelected}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Background" Value="{DynamicResource CbrBackgroundDisabledBrush}"/>
							<Setter Property="Foreground" Value="{DynamicResource CbrForegroundDisabledBrush}"/>
                        </Trigger>                       
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>                
    </Style>    
    
</ResourceDictionary>